
import { scrollMixin } from "utils/mixin";

export default {
  mixins: [scrollMixin], //加载更多
  data() {
    return {
      activeName:0,
      new_content:[],
      //加载更多
      isLoadMore: false,
      total_page: 0,
      page: 1,
      keyword:"",
      urlList:["xj.fhc1userlist","xj.fhc2userlist","xj.fhc3userlist","xj.fhc4userlist"],
    }
  },
  mounted(){
    this.getData();
  },
  methods:{
    getMoreData() {
      const that = this;
      
      if (this.page >= this.total_page) {
        return;
      } else {
        this.page = this.page + 1;
        let json = {
          "page": this.page,
          "keyword": this.keyword,
          "current_page":this.page,
          "last_page":this.last_page,
        }
        $http.get( this.urlList[this.activeName], json, "").then(function (response) {
          that.isLoadMore = true;
          if (response.result === 1) {
            that.new_content = that.new_content.concat(response.data.data);
          } else {
            console.log(response.msg);
            // that.isLoadMore = false;
            this.page--;
          }
        }, function (response) {
          // error callback
          this.page--;
        });

      }
    
    },
    enterSearch(event) {
      if (event.keyCode === 13) {
        //如果按的是enter键
        event.preventDefault();
        this.getData();
      }
    },
    handleClick(){
      this.keyword = ""
      this.getData();
    },
    getData(){
      let that = this;
      let json = {
        "page": this.page,
        "keyword": this.keyword,
        "current_page":this.page,
        "last_page":this.last_page,
      }
      $http.get(this.urlList[this.activeName], json, "").then(function (response) {
        if (response.result === 1) {
          that.new_content = response.data.data;
          that.page = response.data.current_page;
          that.total_page = response.data.last_page;
          console.log(that.new_content)
        } else {
          console.log(response.msg);
        }
      }, function (response) {
        // error callback
      });
    },
  },
}